package org.baitu.zzim.producer;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.baitu.zzim.model.ChatMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhangkai_a
 * @date 2025/7/9 11:37
 */
@Component
public class ChatMessageProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    // 发送顺序消息到指定节点topic
    public void sendMessage(Object message,String userId) {
        String topic = "im-chat";
        // message.getReceiver() 做为消息队列选择的key，保证顺序
        rocketMQTemplate.syncSendOrderly(topic, message, userId);
    }
}